﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ELF
{
    public class ConsulOptions
    {
        /// <summary>
        /// Consul地址
        /// </summary>
        public string Address { get; set; } = default!;
        /// <summary>
        /// 服务名称
        /// </summary>
        public string ServiceName { get; set; } = default!;
        /// <summary>
        /// 服务地址
        /// </summary>
        public string ServiceAddress { get; set; } = default!;
        /// <summary>
        /// 健康检查地址
        /// </summary>
        public string HealthCheckEndpoint { get; set; } = "/health"!;

        private bool? isValidate = null;

        public bool IsValid()
        {
            if (isValidate != null)
                return isValidate.Value;

            if (string.IsNullOrEmpty(Address) ||
                string.IsNullOrEmpty(ServiceName) ||
                string.IsNullOrEmpty(ServiceAddress))
            {
                isValidate = false;
                return false;
            }

            isValidate = true;
            return true;
        }
    }
}
